<html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>学习畅</title>
    <link rel="stylesheet" type="text/css" th:href="@{css1/css.css}"  />
</head>
<style>
    .p{mso-fills-color: #f1f1f1;color: #f1f1f1}
    .p1{font-weight: bold}
    .p2{font-size:3px}
</style>
<body>
<div class="wrap clearfix">
    <!-- left nav start -->
    <div class="index_left fl">
        <div th:align="center"><img class="u_img" width="100px" height="100px" th:src="@{${course.img_src}} "></div>
            <p id="cname" class="p" style="text-align: center" th:text="${course.name}">课程名</p>
        <div class="nav" >
            <ul th:each="chapter:${chapters}">
                <li><a href="" th:id="${chapter}" th:text="${chapter}" onclick="ppt(this)">章节</a></li>
            </ul>
            <hr/>
            <ul>
                <li>笔记</a></li>
                    <textarea id="note" type="note" name="note" clos="60" rows="5" warp="virtual"></textarea>
                <button th:id="${course.name}"type="button" value="收藏" class="store" name="store1" style="float: right; width: 33%;" onclick="save_note(this)">保存</button>
            </ul>
        </div>
    </div>
    <!-- left nav end-->
    <div class="index_right fr">
        <!--    <div class="banner"><img th:src="@{images/back.jpg}" /></div>-->
        <div class="main">
            <div class="index_show">
                <div class="title">章节内容</div>
                <div class="projects-holder clearfix">
                    <iframe id="rightMain" src="http://localhost:8080/content" width="900" height="500"></iframe>
                </div>

            </div>
        </div>

    </div>

</div>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
    function ppt(self){
        // var name= $("#h5").text();
        // alert(self.getAttribute('id'));
        $.ajax({
            type:'POST',
            url:'ucontent',
            data:{"chapter":self.getAttribute('id')},
            dataType:"text",
            traditional:true,
            success:function (data) {
                window.location.href = 'http://localhost:8080/course';
            },
            error:function(XMLHttpRequest,textStatus,errorThrow){
                alert("学习课程失败，请检查网络");
            }
        })
    }
    function save_note(self){
        var note= document.getElementById('note').value;
        $.ajax({
            type:'POST',
            url:'write_note',
            data:{
                "cname":self.getAttribute('id'),
                "note": note,
            },
            dataType:"text",
            traditional:true,
            success:function () {
                alert("保存成功")
            },
            error:function(XMLHttpRequest,textStatus,errorThrow){
                alert("保存失败");
            }
        })
    }
</script>
</body>
</html>
